/*
 * Created on Feb 2, 2005
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package com.broadvision.manage.common.tools.action.common;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.PropertyUtils;
import org.apache.struts.Globals;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;

import com.broadvision.data.client.DataManager;
import com.broadvision.data.common.CallSettings;
import com.broadvision.data.common.DataConstants;

/**
 * @author kwlee
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class UncategorizedCntPickerPopupAction extends BasePickerPopupAction {

  /* (non-Javadoc)
   * @see com.broadvision.portal.tools.util.BasePickerPopupAction#getList(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
   */
  public List getList(
    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws Exception {

    DynaActionForm pickerPopupForm = (DynaActionForm)form;
    if (pickerPopupForm == null || mapping == null) {
      request.setAttribute(Globals.ERROR_KEY, "error.application");
      return new ArrayList();
    }
    
    DataManager dm = new DataManager();
    CallSettings callsettings = dm.getCallSettings();
    callsettings.setFilteringFlag(false);
    int cntTypeId = Integer.parseInt((String)PropertyUtils.getSimpleProperty(pickerPopupForm, "contentTypeId"));
    int serviceId = getServiceId(request);
    long[] ids = dm.getUnclassifiedMemberIds(DataConstants.DEFAULT_CATEGORY_TYPE_ID,
                                              serviceId,
                                              cntTypeId);
    return dm.getContents(cntTypeId, serviceId, ids);
  }

  /* (non-Javadoc)
   * @see com.broadvision.portal.tools.util.BasePickerPopupAction#getTabPageIndex()
   */
  public int getTabPageIndex() {
    return 2;
  }

}
